<!DOCTYPE html>
<html lang="en">

@{
    var body = RenderBody();
    var bodyDoc = new HtmlDocument();
    using var sw = new StringWriter();
    body.WriteTo(sw, HtmlEncoder.Default);
    bodyDoc.LoadHtml(sw.ToString());
    var giscusRepo = string.Empty;
    var giscusRepoId = string.Empty;
    var giscusCategory = string.Empty;
    var giscusCategoryId = string.Empty;
    var title = Model.GetString("Title");
    var toc = Model.GetToc();
    string? desc = null; 
    toc?.Node?.Metadata?.TryGetValue("Description", out desc);
    string? previewImage = null; 
    if (toc?.Node?.Metadata?.TryGetValue("PreviewImage", out previewImage) ?? false)
    {
        previewImage = "https://dotnet.github.io/Silk.NET/" + previewImage;
    }
}

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
  
  @if (title is null || (!(toc is null) && toc.Root == toc.Node))
  {
      <title>
        Silk.NET - High-Speed &amp; Advanced .NET Graphics &amp; Compute
      </title>
  }
  else
  {
      <title>
        @title - Silk.NET
      </title>
      <meta property="og:title" content="@title" />
      <meta property="og:site_name" content="Silk.NET - High-Speed &amp; Advanced .NET Graphics &amp; Compute" />
  }

  @if (desc is null)
  {
      string? firstParagraph = null;
      if (IsBlogPost && !string.IsNullOrWhiteSpace(firstParagraph = bodyDoc.DocumentNode.SelectNodes("//p[not(@id) and not(@class)]").FirstOrDefault()?.InnerText))
      {
          <meta name="description" content="@firstParagraph" />
      }
      else
      {
          <meta name="description" content="Your one-stop-shop for high performance .NET graphics &amp; compute. A .NET Foundation project." />
      }
  }
  else
  {
      <meta name="description" content="@desc" />
  }

  @if (IsBlogPost)
  {
      <meta property="og:type" content="article" />
  }
  else
  {
      <meta property="og:type" content="website" />
  }

  @if (previewImage is null)
  {
      <meta name="og:image" content="https://dotnet.github.io/Silk.NET/images/logo64.png" />
      <meta name="og:image:alt" content="Silk.NET Logo" />
      <meta name="twitter:card" content="summary" />
  }
  else
  {
      <meta name="og:image" content="@previewImage" />
      <meta name="og:image:alt" content="Blog Preview Image" />
      <meta name="twitter:card" content="summary_large_image" />
  }

  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />
  <link href="@InputUrl("theme/nucleo.css")" rel="stylesheet" />
  <link href="@InputUrl("theme/fontawesome.css")" rel="stylesheet" />
  <link href="@InputUrl("theme/argon.css")" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/nord.min.css">
  <link rel="stylesheet" href="@InputUrl("theme/silk.css")" />
</head>

<body class="silk-dark">
  @Html.Partial("_theme/src/10-nav.cshtml")
  @Html.Partial("_theme/src/20-contentroot.cshtml", new ViewDataDictionary(ViewData) { { "body", body }})
  <script src="@InputUrl("theme/jquery.min.js")" type="text/javascript"></script>
  <script src="@InputUrl("theme/popper.min.js")" type="text/javascript"></script>
  <script src="@InputUrl("theme/bootstrap.min.js")" type="text/javascript"></script>
  <script async defer src="https://buttons.github.io/buttons.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script>
  <script src="@InputUrl("theme/argon.js")" type="text/javascript"></script>
  <script src="@InputUrl("theme/clipboard.min.js")"></script>
  <script src="@InputUrl("theme/headroom.min.js")"></script>
  <script src="@InputUrl("theme/silk.js")"></script>
  @if ((toc?.Root?.Metadata?.TryGetValue("theme.silk.giscus.repo", out giscusRepo) ?? false) &&
       (toc?.Root?.Metadata?.TryGetValue("theme.silk.giscus.repo.id", out giscusRepoId) ?? false) &&
       (toc?.Root?.Metadata?.TryGetValue("theme.silk.giscus.category", out giscusCategory) ?? false) &&
       (toc?.Root?.Metadata?.TryGetValue("theme.silk.giscus.category.id", out giscusCategoryId) ?? false) &&
       (!toc?.Node?.Metadata?.ContainsKey("theme.silk.giscus.exempt") ?? true))
  {
      <script src="https://giscus.app/client.js"
              data-repo="@giscusRepo"
              data-repo-id="@giscusRepoId"
              data-category="@giscusCategory"
              data-category-id="@giscusCategoryId"
              data-mapping="pathname"
              data-strict="0"
              data-reactions-enabled="1"
              data-emit-metadata="0"
              data-input-position="bottom"
              data-theme="preferred_color_scheme"
              data-lang="en"
              crossorigin="anonymous"
              async>
      </script>
  }
</body>

</html>